<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<script>
	window.onload = function()
	{
			 var oBtn = document.getElementById('btn1');
				var oUl = document.getElementById('ul1');
				var oTxt = document.getElementById('txt1');
		
				oBtn.onclick = function()
				{
						var oLi = document.createElement('li');
						var aLi = oUl.getElementsByTagName('li');
						oLi.innerHTML = oTxt.value;
						//父级 添加 子节点
						//oUl.appendChild(oLi);
					if(aLi.length>0)
					{
								oUl.insertBefore(oLi,aLi[0]);
					}
					else{
								oUl.appendChild(oLi);
					}
				};
	};
	</script>
</head>

<body>
<input type="text" id="txt1">
<input type="button" id="btn1" value="Createli">
<ul id="ul1">
	
</ul>
</body>
</html>
